package com.mvc.loadconfig;

import java.util.ArrayList;
import java.util.List;

public class GetBeanpath {
	private List<String> actionpathlist;
	private List<String> formpathlist;

	public void setActionpathlist(List<String> actionpathlist) {
		this.actionpathlist = actionpathlist;
	}

	public void setFormpathlist(List<String> formpathlist) {
		this.formpathlist = formpathlist;
	}

	public List<String> getActionpathlist() {
		return actionpathlist;
	}

	public List<String> getFormpathlist() {

		return formpathlist;
	}

	public GetBeanpath(String path) {
		String suffix = "class";
		List<String> list = FileViewer.getListFiles(path, suffix, true);
		String actionfilter = "Action.class";
		String formfilter = "Form.class";
		this.actionpathlist = new ArrayList<String>();
		this.formpathlist = new ArrayList<String>();
		for (String filepath : list) {
			if (filepath.indexOf(actionfilter) != -1) {
				actionpathlist.add(filepath.substring(path.length()).split(
						"\\.")[0].replace("\\", "."));
			} else if (filepath.indexOf(formfilter) != -1) {
				formpathlist
						.add(filepath.substring(path.length()).split("\\.")[0]
								.replace("\\", "."));
			}
		}
	}

	public static void main(String[] args) {
		String path = "E:\\tomcat2\\webapps\\mvc4\\WEB-INF\\classes\\";
		GetBeanpath gbp = new GetBeanpath(path);
		List<String> actionpathlist = gbp.getActionpathlist();
		List<String> formpathlist = gbp.getFormpathlist();
		for (String actionpath : actionpathlist) {
			System.out.println(actionpath);
		}
		for (String formpath : formpathlist) {
			System.out.println(formpath);
		}
	}
}
